import axios from "axios";


let axiosInstance = axios.create({
    baseURL: "/api",
    timeout: 30000,

})

axiosInstance.interceptors.request.use((request)=>{
    const token = localStorage.getItem("login")
    request.headers.token = token;
    return request
})

axiosInstance.interceptors.response.use((response) => {
        const data = response.data;
        if (data.code===500){
            return Promise.reject(new Error(data.message))
        }
        return data;
    },err=>{
        return Promise.reject(err)
    }
)

export {axiosInstance}